//
//  ICMineNetworkManager.m
//  ICome
//
//  Created by zhangrongwu on 16/9/26.
//  Copyright © 2016年 iCom. All rights reserved.
//

#import "ICChatNetworkManager.h"
#import "ICHeaderFile.h"


@implementation ICChatNetworkManager

+(instancetype)sharedInstance {
    static ICChatNetworkManager *manager;
    static dispatch_once_t once;
    dispatch_once(&once, ^{
        manager = [[ICChatNetworkManager alloc] init];
    });
    return manager;
}


// 收藏
- (void)addFavoriteWithParam:(NSDictionary *)param
                     Success:(HttpSuccessCompletionHandle)success
                     failure:(HttpFailureCompletionHandle)failure {
    NSString *url = [self appendRequestBaseURL:MINE_ADD_FAVORITE];
   
    [ICNetworkHelper POST:url parameters:param success:^(id responseObject) {
        success(responseObject);
    } failure:^(NSError *error) {
        failure(error); 
    }];
}

// 判断是否收藏
- (void)judgeFavoriteWithParam:(NSDictionary *)param
                       Success:(HttpSuccessCompletionHandle)success
                       failure:(HttpFailureCompletionHandle)failure
{
    NSString *url = [self appendRequestBaseURL:MINE_FIND_FAVORITE];
    
    [ICNetworkHelper POST:url parameters:param success:^(id responseObject) {
        success(responseObject);
    } failure:^(NSError *error) {
        failure(error);
    }];
}



- (void)getPubMenuWithParam:(NSDictionary *)param
               requestCache:(RequestCache)cache
                    Success:(HttpSuccessCompletionHandle)success
                    failure:(HttpFailureCompletionHandle)failure {
    NSString *url = [self appendRequestBaseURL:@"customer/getMenu"];
    [ICNetworkHelper POST:url parameters:param responseCache:^(id responseCache) {
        cache(responseCache);
    } success:^(id responseObject) {
        success(responseObject);
    } failure:^(NSError *error) {
        failure(error);
    }];
}

- (void)getCustomerWithParam:(NSDictionary *)param
                requestCache:(RequestCache)cache
                     Success:(HttpSuccessCompletionHandle)success
                     failure:(HttpFailureCompletionHandle)failure {
    NSString *url = [self appendRequestBaseURL:@"customer/customerServiceList"];
    [ICNetworkHelper POST:url parameters:param responseCache:^(id responseCache) {
        cache(responseCache);
    } success:^(id responseObject) {
        success(responseObject);
    } failure:^(NSError *error) {
        failure(error);
    }];
}

- (void)transferCustomerWithParam:(NSDictionary *)param
                          Success:(HttpSuccessCompletionHandle)success
                          failure:(HttpFailureCompletionHandle)failure {
    NSString *url = [self appendRequestBaseURL:@"customer/transfer"];
    [ICNetworkHelper POST:url parameters:param success:^(id responseObject) {
        success(responseObject);
    } failure:^(NSError *error) {
        failure(error);
    }];
}

- (void)getTopMessageWithParam:(NSDictionary *)param
                       Success:(HttpSuccessCompletionHandle)success
                       failure:(HttpFailureCompletionHandle)failure {
    NSString *url = [self appendRequestBaseURL:@"imserver/getTop"];
    [ICNetworkHelper POST:url parameters:param success:^(id responseObject) {
        success(responseObject);
    } failure:^(NSError *error) {
        failure(error);
    }];
}

@end
